IF OBJECT_ID ( 'sp_Obter_Pedido_Por_Status', 'P' ) IS NOT NULL 
    DROP PROCEDURE sp_Obter_Pedido_Por_Status
GO

CREATE PROCEDURE sp_Obter_Pedido_Por_Status
AS

SELECT
	 spe.spe_des_status_pedido
	,COUNT(ped.ped_idt_pedido) AS ped_qtd_pedido
	,SUM(ped.ped_vlr_total_pedido) AS ped_vlr_total_pedido 
FROM
	tb_ped_pedido ped
INNER JOIN
	tb_spe_status_pedido spe
ON
	ped.spe_idt_status_pedido = spe.spe_idt_status_pedido
GROUP BY
	spe.spe_des_status_pedido
GO